package sample;

import javafx.application.Application;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.concurrent.Worker;
import javafx.concurrent.Worker.State;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;


public class Hello extends Application {

	@Override
	public void start(final Stage stage) {

		stage.setWidth(960);
		stage.setHeight(800);
		stage.setMaximized(true);
		Scene scene = new Scene(new Group());


		final WebView browser = new WebView();
		final WebEngine webEngine = browser.getEngine();

		ScrollPane scrollPane = new ScrollPane();
		scrollPane.setContent(browser);

		Worker<Void> worker = webEngine.getLoadWorker();
		ReadOnlyObjectProperty<State> objectProperty = worker.stateProperty();
		ChangeListenerDemo listenerDemo = new ChangeListenerDemo(webEngine, stage);
		objectProperty.addListener(listenerDemo);

		webEngine.load("https://auth.alipay.com/login/index.htm?goto=https%3A%2F%2Fwww.alipay.com%2F");

		scene.setRoot(scrollPane);

		stage.setScene(new Scene(browser, stage.getWidth(), stage.getHeight()));
		stage.show();
	}

	public static void main(String[] args) {
		launch(args);
	}

}
